
        <!-- Content Header (Page header) -->

        <!-- Main content -->
        <section class="content container-fluid">
            <div class="row">
                <div class="col-xs-12">
                    <div class="box">
                        <div class="box-header with-border">
                            <button type="button" class="btn btn-success" onclick="gm.reCategory()">
                                自动分类
                            </button>
                        </div>
                        <div class="box-body" id="tags" style="line-height:1.8">
                            <#list tags as tag>
                                <span class="label label-default tag" data-tagid="${tag.id}" style="cursor: pointer;">${tag.name!''}</span>
                            </#list>
                            <span class="label label-default" data-toggle="modal" data-target="#tagAdd" style="cursor: pointer;">
                                <span class="glyphicon glyphicon-plus"></span>
                            </span>
                            <div class="modal fade" id="tagAdd">
                                <div class="modal-dialog">
                                    <div class="modal-content">
                                        <div class="modal-header">
                                            <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                                                <span aria-hidden="true">&times;</span></button>
                                            <h4 class="modal-title">添加一个标签</h4>
                                        </div>
                                        <div class="modal-body">
                                            <!-- form start -->
                                            <form role="form" id="tagAddForm">
                                                <div class="box-body">
                                                    <div class="form-group">
                                                        <label for="goodsName">标签名称</label>
                                                        <input type="text" class="hidden" name="id" id="tagId" value="">
                                                        <input type="text" class="form-control" name="name"
                                                               id="tagName" placeholder="标签名称">
                                                        <input type="number" class="hidden" name="parent" value="0">
                                                    </div>
                                                    <#--<div class="form-group">
                                                        <label for="goodsPosition">上级标签</label>
                                                        <input type="text" class="form-control" name="parent"
                                                               id="parentName" placeholder="上级标签名称">
                                                    </div>-->
                                                </div>
                                                <!-- /.box-body -->
                                            </form>
                                            <!-- /.box -->
                                        </div>
                                        <div class="modal-footer">
                                            <button type="button" class="btn btn-default pull-left"
                                                    data-dismiss="modal">取消
                                            </button>
                                            <button type="button" class="btn btn-primary" id="tagSaveBtn" data-dismiss="modal" onclick="gm.saveTag()">保存</button>
                                        </div>
                                    </div>
                                    <!-- /.modal-content -->
                                </div>
                                <!-- /.modal-dialog -->
                            </div>
                        </div>
                        <!-- /.box-body -->
                    </div>

                </div>
            </div>
            <div class="row">
                <div class="col-xs-12">
                    <div class="box">
                        <div class="box-body table-responsive no-padding">
                            <div class="box-body pull-right">
                                <button onclick="gm.clearForm()" type="button" class="btn btn-sm btn-success " data-toggle="modal"
                                        data-target="#modal-default">
                                    新增
                                </button>
                            </div>
                            <div class="modal fade" id="modal-default">
                                <div class="modal-dialog">
                                    <div class="modal-content">
                                        <div class="modal-header">
                                            <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                                                <span aria-hidden="true">&times;</span></button>
                                            <h4 class="modal-title">添加一个商品</h4>
                                        </div>
                                        <div class="modal-body">
                                            <!-- form start -->
                                            <form role="form" id="goodsAddForm">
                                                <div class="box-body">
                                                    <div class="form-group">
                                                        <label for="goodsName">商品名称</label>
                                                        <input type="text" class="hidden" name="id" id="goodsId" value="">
                                                        <input type="text" class="form-control" name="name"
                                                               id="goodsName" placeholder="商品名称">
                                                    </div>
                                                    <div class="form-group">
                                                        <label for="serialNo">条码</label>
                                                        <input type="text" class="form-control" name="serialNo"
                                                               id="serialNo" placeholder="条码">
                                                    </div>
                                                    <div class="form-group">
                                                        <label for="goodsPosition">货架位</label>
                                                        <input type="text" class="form-control" name="position"
                                                               id="goodsPosition" placeholder="货位">
                                                    </div>
                                                    <div class="form-group">
                                                        <label for="storeCnt">库存</label>
                                                        <input type="text" class="form-control" name="cnt"
                                                               id="storeCnt" placeholder="库存">
                                                    </div>
                                                </div>
                                                <!-- /.box-body -->
                                            </form>
                                            <!-- /.box -->
                                        </div>
                                        <div class="modal-footer">
                                            <button type="button" class="btn btn-default pull-left"
                                                    data-dismiss="modal">取消
                                            </button>
                                            <button type="button" class="btn btn-primary" id="goodsSaveBtn" data-dismiss="modal" onclick="saveGoods()">保存</button>
                                        </div>
                                    </div>
                                    <!-- /.modal-content -->
                                </div>
                                <!-- /.modal-dialog -->
                            </div>
                            <!-- /.modal -->
                            <#include "goodsTable.ftl">
                        </div>
                        <!-- /.box-body -->
                    </div>
                    <!-- /.box -->
                </div>
            </div>

        </section>
        <!-- /.content -->
        <script>
            var table;
            function initPage() {
                $('#tags').find('span.tag').click(function () {
                    if($(this).hasClass('label-primary')){
                        $(this).removeClass('label-primary');
                    }else{
                        var find = $('#tags').find('span.label');
                        find.removeClass('label-primary');
                        find.addClass('label-default');
                        $(this).addClass('label-primary');
                    }
                    table.ajax.reload();
                });
                table = $('#goodsTable').DataTable({
                    'dom': 'rtlp',
                    'serverSide': true,
                    'autoWidth': true,
                    /*scrollY: '100vh',
                    scrollCollapse: true,*/
                    'pageLength': 50,
                    'ajax': {
                        url: '${base}/goodsTable',
                        data: function (data) {
                            data.tagId = $('#tags').find('span.label-primary').data('tagid');
                        }
                    },
                    'columns': [
                        {"data": "id"},
                        {"data": "name"},
                        {
                            "data": "brand.name",
                            "render":function (data) {
                                if(data != null){
                                    return data;
                                }else{
                                    return "";
                                }
                            }
                        },
                        {
                            "data": "serialNo"
                        },
                        {
                            "data": "position"
                        },
                        {
                            "data": "cnt"
                        },{
                            "data":"id",
                            "render":function (data, type, row, meta){
                                return "<button type=\"button\" class=\"btn btn-xs btn-info\" data-toggle=\"modal\"" +
                                        "                                        data-target=\"#modal-default\" onclick=\"editGoods("+meta.row+")\">\n" +
                                        "                                                编辑\n" +
                                        "                                            </button>\n" +
                                        "                                            <button type=\"button\" class=\"btn btn-xs btn-danger\" onclick=\"delGoods("+data+")\">\n" +
                                        "                                                删除\n" +
                                        "                                            </button>"
                            }
                        }
                    ]
                });
            }
        </script>